package com.ruoyi.servie.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AlipayConfiguration {

    @Value("${ali.ALIPAY_GATEWAY}")
    private String ALIPAY_GATEWAY;

    @Value("${ali.APP_ID}")
    private String APP_ID;

    @Value("${ali.APP_PRIVATE_KEY}")
    private String APP_PRIVATE_KEY;

    @Value("${ali.ALIPAY_PUBLIC_KEY}")
    private String ALIPAY_PUBLIC_KEY;

    @Value("${ali.CHARSET}")
    private String CHARSET;

    @Value("${ali.SIGN_TYPE}")
    private String SIGN_TYPE;

    @Value("${ali.FORMAT}")
    private String FORMAT;


    @Bean
    public AlipayClient alipayClient(){
        return new DefaultAlipayClient(ALIPAY_GATEWAY, APP_ID, APP_PRIVATE_KEY,
                FORMAT, CHARSET, ALIPAY_PUBLIC_KEY, SIGN_TYPE);
    }
}

